//
//  WHBaseTableViewCell.m
//  WHPersonalData
//
//  Created by shengmeng chen on 2019/4/20.
//  Copyright © 2019 mac. All rights reserved.
//

#import "WHBaseTableViewCell.h"
#import "SDAutoLayout.h"


@implementation WHBaseTableViewCell

-(void)createUIControls
{
    [super createUIControls];
    /** 头像  **/
    UIImageView*iconImageView =[[UIImageView alloc]init];
    [self.contentView  addSubview:iconImageView];
   // iconImageView.image = [UIImage imageNamed:kWHUserIcon2];
    _iconImageView = iconImageView;

    /**  标题,标题  **/
    UILabel*titleLabel = [[UILabel alloc]init];
    titleLabel.font = [UIFont systemFontOfSize:15*WidthScale>17?17:15*WidthScale];
    titleLabel.textColor =[UIColor blackColor];
    [self.contentView addSubview:titleLabel];
    titleLabel.numberOfLines =0;
    titleLabel.text = @"标题,标题,标题,标题,标题,标题";
    _titleLabel = titleLabel;
    
    /**  时间    **/
    UILabel*timeLabel = [[UILabel alloc]init];
    timeLabel.font = [UIFont systemFontOfSize:11*WidthScale>13?13:11*WidthScale];
    timeLabel.textColor =[UIColor lightGrayColor];
    timeLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:timeLabel];
    timeLabel.text = @"下午6:30";
    _timeLabel = timeLabel;
    
    /**  副标题    **/
    UILabel*detailLabel = [[UILabel alloc]init];
    detailLabel.font = [UIFont systemFontOfSize:12*WidthScale>14?14:12*WidthScale];
    detailLabel.textColor =[UIColor lightGrayColor];
    [self.contentView addSubview:detailLabel];
    detailLabel.numberOfLines =0;
    _detailLabel = detailLabel;
    _detailLabel.text = @"副标题/副标题/副标题/副标题/副标题/副标题";
    /**  分割线     **/
    UIView*separatorLine =[[UIView alloc]init];
    separatorLine.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:separatorLine];
    _separatorLine = separatorLine;
}

-(void)setUpUIControlsLayout
{
    [super setUpUIControlsLayout];
    
    /**   图片   **/
    self.iconImageView.sd_layout
    .topSpaceToView(self.contentView,kMarginH*0.75)
    .leftSpaceToView(self.contentView,kMarginH)
    .widthIs(4*kMarginH)
    .heightIs(4*kMarginH);
    self.iconImageView.layer.cornerRadius =3;
    self.iconImageView.layer.masksToBounds = YES;
    
    /**   标题,标题  **/
    _titleLabel.sd_layout.
    topSpaceToView(self.contentView,kMarginH)
    .leftSpaceToView(self.iconImageView,kMarginH)
    .rightSpaceToView(self.contentView,kMarginH)
    .autoHeightRatio(0);
    
    /**  时间    **/
    _timeLabel.sd_layout
    .topSpaceToView(self.contentView,kMarginH)
    .rightSpaceToView(self.contentView,kMarginH)
    .widthIs(kMarginH*10)
    .autoHeightRatio(0);
    
    /**  副标题    **/
    _detailLabel.sd_layout.
    topSpaceToView(self.titleLabel,5)
    .leftSpaceToView(self.iconImageView,kMarginH)
    .rightSpaceToView(self.contentView,kMarginH)
    .autoHeightRatio(0);
    
    /**  分割线     **/
    self.separatorLine.sd_layout
    .leftEqualToView(self.contentView)
    .rightEqualToView(self.contentView)
    .bottomEqualToView(self.contentView)
    .heightIs(1);
    
    [self setupAutoHeightWithBottomViewsArray:@[self.iconImageView,self.detailLabel] bottomMargin:kMarginH];
}

@end
